#include <unistd.h>
#include <stdlib.h>

#include "stack.h"

struct s_stack
{
    void        *elem;
    stack       next;
};


stack push (void *x, stack s)
{
    stack       tmp = NULL;

    tmp = malloc (sizeof (struct s_stack));
    tmp->elem = x;
    tmp->next = s;

    s = tmp;

    return s;
}

void *pop (stack *s)
{
    void        *el = NULL;
    stack       tmp = NULL;

    el = (*s)->elem;
    tmp = (*s)->next;

    free(*s);

    (*s) = tmp;

    return el;
}
